@Start:
GoToIfSleeping(@Wait)
GoToIfFatigueAbove(@Sleep,96)
GoToIfNPCNear(@Mage,262)
Wait(500)
GoTo(@Start)

@Wait:
WaitForWakeUp()
GoTo(@Start)

@Sleep:
UseItemByID(1263)
Wait(2000)
GoTo(@Start)

@Mage:
MagicNPC(262,11)
Wait(300)
GoTo(@Start)